﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using TLTuan.App.TransferObj;
using System.Collections.Generic;
using System.Data.SqlClient;

namespace TLTuan.App.AccessLayer
{
    public class CDAONhomTLLienQuan
    {
        public DataTable SelectAll2Dt()
        {
            return CConnection.GetData("pr_tblNhomTLlienquan_SelectAll");
        }

        public List<CNhomTLLienQuan> SelectAll2Obj()
        {
            DataTable v_dt = this.SelectAll2Dt();
            if (v_dt == null || v_dt.Rows.Count == 0)
                return null;
            else
            {
                List<CNhomTLLienQuan> op_lst = new List<CNhomTLLienQuan>();
                foreach (DataRow item in v_dt.Rows)
                {
                    op_lst.Add(convertDataRow2Obj(item));
                }

                return op_lst;
            }
        }

        #region Method ...

        private CNhomTLLienQuan convertDataRow2Obj(DataRow ip_dr)
        {
            // Khoi tao
            CNhomTLLienQuan op_nhomtllienquan = new CNhomTLLienQuan();

            // Gan cac thuoc tinh
            op_nhomtllienquan.PK_NhomTLID = int.Parse(ip_dr["PK_NhomTL"].ToString());
            op_nhomtllienquan.Manhom = ip_dr["Manhom"].ToString();
            op_nhomtllienquan.Tennhom = ip_dr["Tennhom"].ToString();
            return op_nhomtllienquan;
        }

        #endregion

    }
}
